/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidad;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author a
 */
@Entity
@Table(name = "comanda_has_platillo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ComandaHasPlatillo.findAll", query = "SELECT c FROM ComandaHasPlatillo c"),
    @NamedQuery(name = "ComandaHasPlatillo.findByComandaidComanda", query = "SELECT c FROM ComandaHasPlatillo c WHERE c.comandaHasPlatilloPK.comandaidComanda = :comandaidComanda"),
    @NamedQuery(name = "ComandaHasPlatillo.findByPlatilloidPlatillo", query = "SELECT c FROM ComandaHasPlatillo c WHERE c.comandaHasPlatilloPK.platilloidPlatillo = :platilloidPlatillo"),
    @NamedQuery(name = "ComandaHasPlatillo.findByCantidad", query = "SELECT c FROM ComandaHasPlatillo c WHERE c.cantidad = :cantidad"),
    @NamedQuery(name = "ComandaHasPlatillo.findBySubtotal", query = "SELECT c FROM ComandaHasPlatillo c WHERE c.subtotal = :subtotal"),
    @NamedQuery(name = "ComandaHasPlatillo.findByAnulado", query = "SELECT c FROM ComandaHasPlatillo c WHERE c.anulado = :anulado")})
public class ComandaHasPlatillo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ComandaHasPlatilloPK comandaHasPlatilloPK;
    @Basic(optional = false)
    @Column(name = "cantidad")
    private float cantidad;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "subtotal")
    private Float subtotal;
    @Column(name = "anulado")
    private Boolean anulado;
    @JoinColumn(name = "Platillo_idPlatillo", referencedColumnName = "idPlatillo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Platillo platillo;
    @JoinColumn(name = "Comanda_idComanda", referencedColumnName = "idComanda", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Comanda comanda;

    public ComandaHasPlatillo() {
    }

    public ComandaHasPlatillo(ComandaHasPlatilloPK comandaHasPlatilloPK) {
        this.comandaHasPlatilloPK = comandaHasPlatilloPK;
    }

    public ComandaHasPlatillo(ComandaHasPlatilloPK comandaHasPlatilloPK, float cantidad) {
        this.comandaHasPlatilloPK = comandaHasPlatilloPK;
        this.cantidad = cantidad;
    }

    public ComandaHasPlatillo(int comandaidComanda, int platilloidPlatillo) {
        this.comandaHasPlatilloPK = new ComandaHasPlatilloPK(comandaidComanda, platilloidPlatillo);
    }

    public ComandaHasPlatilloPK getComandaHasPlatilloPK() {
        return comandaHasPlatilloPK;
    }

    public void setComandaHasPlatilloPK(ComandaHasPlatilloPK comandaHasPlatilloPK) {
        this.comandaHasPlatilloPK = comandaHasPlatilloPK;
    }

    public float getCantidad() {
        return cantidad;
    }

    public void setCantidad(float cantidad) {
        this.cantidad = cantidad;
    }

    public Float getSubtotal() {
        return subtotal;
    }

    public void setSubtotal(Float subtotal) {
        this.subtotal = subtotal;
    }

    public Boolean getAnulado() {
        return anulado;
    }

    public void setAnulado(Boolean anulado) {
        this.anulado = anulado;
    }

    public Platillo getPlatillo() {
        return platillo;
    }

    public void setPlatillo(Platillo platillo) {
        this.platillo = platillo;
    }

    public Comanda getComanda() {
        return comanda;
    }

    public void setComanda(Comanda comanda) {
        this.comanda = comanda;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (comandaHasPlatilloPK != null ? comandaHasPlatilloPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ComandaHasPlatillo)) {
            return false;
        }
        ComandaHasPlatillo other = (ComandaHasPlatillo) object;
        if ((this.comandaHasPlatilloPK == null && other.comandaHasPlatilloPK != null) || (this.comandaHasPlatilloPK != null && !this.comandaHasPlatilloPK.equals(other.comandaHasPlatilloPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidad.ComandaHasPlatillo[ comandaHasPlatilloPK=" + comandaHasPlatilloPK + " ]";
    }
    
}
